//package com.demo.xmtx.handler;
//
//import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
//import org.apache.ibatis.type.JdbcType;
//import org.apache.ibatis.type.TypeHandler;
//import org.locationtech.jts.geom.Geometry;
//import org.locationtech.jts.io.ParseException;
//import org.locationtech.jts.io.WKTReader;
//import org.locationtech.jts.io.WKTWriter;
//
//import java.sql.CallableStatement;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//
//public class GeometryTypeHandler implements AbstractJsonTypeHandler<Geometry> {
//
//    private final WKTReader wktReader = new WKTReader();
//    private final WKTWriter wktWriter = new WKTWriter();
//
////
////    @Override
////    public void setNonNullParameter(PreparedStatement ps, int i, Geometry parameter, JdbcType jdbcType) throws SQLException {
////        ps.setString(i, wktWriter.write(parameter));
////    }
////
////    @Override
////    public Geometry getNullableResult(ResultSet rs, String columnName) throws SQLException {
////        try {
////            return wktReader.read(rs.getString(columnName));
////        } catch (ParseException e) {
////            throw new SQLException("Failed to parse geometry", e);
////        }
////    }
////
////    @Override
////    public Geometry getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
////        try {
////            return wktReader.read(rs.getString(columnIndex));
////        } catch (ParseException e) {
////            throw new SQLException("Failed to parse geometry", e);
////        }
////    }
////
////    @Override
////    public Geometry getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
////        try {
////            return wktReader.read(cs.getString(columnIndex));
////        } catch (ParseException e) {
////            throw new SQLException("Failed to parse geometry", e);
////        }
////    }
//}